<template>
  <div class="fillcontain">
    <head-top></head-top>
    <div class="table_container">
      进度监控-{{stuname}}
      <div>仿真进度
      <div>
        验证点：
      </div>
      </div>

      <div>实训进度
      <div>
        放个tables
        数据源／正常范围／当前值／状态
      </div>
      </div>
    </div>
  </div>
</template>

<script>
  import headTop from './head.vue'
  import { DeviceType, DeviceTypeAdd, DeviceTypeDel } from '@/api/api'
  export default {
    data () {
      return {
        filters: {
          name: ''
        },
        loading: false,
        DTypes: [
        ],
        selectTable: { name: '' },
        dialogFormVisible: false,
        menuOptions: [],
        selectMenu: {},
        selectIndex: null,
        stuname: 'stu'
      }
    },
    components: {
      headTop
    },
    created () {
      this.initData()
    },
    methods: {
      // 获取设备类型
      async initData () {
        this.loading = true
        this.selectTable.name = '' // 重置输入框内容
        try {
          DeviceType().then((res) => {
            this.DTypes = res.data
            this.loading = false
          })
        } catch (err) {
          console.log('获取数据失败', err)
        }
      },
      handleAdd () {
        this.dialogFormVisible = true
      },
      async createType () {
        this.dialogFormVisible = false
        let postData = { name: this.selectTable.name }
        DeviceTypeAdd(postData).then(res => {
          if (res.status === 201) {
            this.$message({
              type: 'success',
              message: '添加成功'
            })
            this.initData()
          } else {
            this.$message({
              type: 'error',
              message: '添加失败'
            })
          }
        }).catch(error => {
          this.$message({
            type: 'error',
            message: '添加失败'
          })
          console.log('类型添加失败', error)
        })
      },
      async handleDelete (index, row) {
        DeviceTypeDel(row.id).then((res) => {
          this.$message({
            type: 'success',
            message: '删除成功'
          })
          this.Dtypes.splice(index, 1)
        }).catch(error => {
          this.$message({
            type: 'error',
            message: '删除失败'
          })
          console.log('类型删除失败', error)
        })
      }
    }
  }

</script>

<style scoped>

</style>
